/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.easoft.code.pos.data.pojos;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Eliu
 */
@Entity
@Table(name = "precio")
@NamedQueries({
    @NamedQuery(name = "Precio.findAll", query = "SELECT p FROM Precio p"),
    @NamedQuery(name = "Precio.findByRecargo", query = "SELECT p FROM Precio p WHERE p.recargo = :recargo"),
    @NamedQuery(name = "Precio.findByEstado", query = "SELECT p FROM Precio p WHERE p.estado = :estado"),
    @NamedQuery(name = "Precio.findById", query = "SELECT p FROM Precio p WHERE p.id = :id")})
public class Precio implements Serializable {

    @Basic(optional = false)
    @Column(name = "tipo_recargo")
    private int tipoRecargo;
    @Column(name = "tipo_precio")
    private Integer tipoPrecio;

    private static final long serialVersionUID = 1L;

    @Basic(optional = false)
    @Column(name = "recargo")
    private float recargo;
    @Basic(optional = false)
    @Column(name = "estado")
    private int estado;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @JoinColumn(name = "producto", referencedColumnName = "codigo")
    @ManyToOne(optional = false, cascade = CascadeType.ALL)
    private Producto producto;

    public Precio() {
    }

    public Precio(Integer id) {
        this.id = id;
    }

    public Precio(Integer id, float recargo, int estado, int tipo) {
        this.id = id;
        this.recargo = recargo;
        this.estado = estado;
        this.tipoPrecio = tipo;
    }

    public float getRecargo() {
        return recargo;
    }

    public void setRecargo(float recargo) {
        this.recargo = recargo;
    }

    public int getEstado() {
        return estado;
    }

    public void setEstado(int estado) {
        this.estado = estado;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Producto getProducto() {
        return producto;
    }

    public void setProducto(Producto producto) {
        this.producto = producto;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Precio)) {
            return false;
        }
        Precio other = (Precio) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.easoft.code.pos.data.pojos.Precio[ id=" + id + " ]";
    }

    public int getTipoRecargo() {
        return tipoRecargo;
    }

    public void setTipoRecargo(int tipoRecargo) {
        this.tipoRecargo = tipoRecargo;
    }

    public Integer getTipoPrecio() {
        return tipoPrecio;
    }

    public void setTipoPrecio(Integer tipoPrecio) {
        this.tipoPrecio = tipoPrecio;
    }

}
